package com.example.demo.mapper;

import com.example.demo.pojo.entity.Component;
import com.example.demo.pojo.entity.Inbound;
import com.example.demo.pojo.entity.Outbound;
import com.example.demo.pojo.entity.Storage;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
public interface DataMapper {
    @Select("select * from warehouse.components")
    ArrayList<Component> getComponent();;
    @Select("select * from warehouse.storage")
    ArrayList<Storage> getStorage();
    @Select("select Sum(in_quantity) from warehouse.inbound where update_time > #{before} and update_time < #{now}")
    int selectInboundBy(@Param("before") LocalDateTime before, @Param("now") LocalDateTime now);
    @Select("select Sum(in_quantity) from warehouse.inbound where update_time > #{before} and update_time < #{now}")
    Integer selectInboundByDate(@Param("before") LocalDateTime before, @Param("now") LocalDateTime now);
    @Select("select Sum(out_quantity) from warehouse.outbound where update_time > #{before} and update_time < #{now}")
    Integer selectOutboundByDate(@Param("before") LocalDateTime before, @Param("now") LocalDateTime now);
    @Select("SELECT category, COUNT(*) AS category_count FROM warehouse.components GROUP BY category")
     List<Map<Integer, Integer>> selectCategory();
    @Select("select count(*) from warehouse.inventory ")
    Integer selectInComponent();
    @Select("select count(*) from warehouse.components where update_time > #{before} and update_time < #{now}")
    Integer selectComponentByDate(@Param("before") LocalDateTime before, @Param("now") LocalDateTime now);

    @Select("select count(*) from warehouse.storage where update_time > #{before} and update_time < #{now}")
    Integer selectStorageByDate(@Param("before") LocalDateTime before, @Param("now") LocalDateTime now);
}
